﻿'   FAHWatch7 Copyright (c) 2011 Marvin Westmaas ( MtM / Marvin_The_Martian )
'
'   This program is free software: you can redistribute it and/or modify
'   it under the terms of the GNU General Public License as published by
'   the Free Software Foundation, either version 3 of the License, or
'   (at your option) any later version.
'
'   This program is distributed in the hope that it will be useful,
'   but WITHOUT ANY WARRANTY; without even the implied warranty of
'   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'   GNU General Public License for more details.
'
'   You should have received a copy of the GNU General Public License
'   along with this program.  If not, see <http://www.gnu.org/licenses/>.
'
Public Class clsFilters
#Region "Filter collection"
    Private mFilters As New Dictionary(Of String, String)
    Public ReadOnly Property Filters As Dictionary(Of String, String)
        Get
            Return mFilters
        End Get
    End Property
    Public ReadOnly Property FilterNames As List(Of String)
        Get
            Return mFilters.Keys.ToList
        End Get
    End Property
    Public Function AddFilter(Name As String, sql As String) As Boolean
        Try
            If mFilters.ContainsKey(Name) Then
                mFilters(Name) = sql
                Return True
            End If
            If mFilters.ContainsValue(sql) Then Return False
            mFilters.Add(Name, sql)
            Return True
        Catch ex As Exception
            WriteError(ex.Message, Err)
            Return False
        End Try
    End Function
    Public ReadOnly Property sql(FilterName As String) As String
        Get
            If Not mFilters.ContainsKey(FilterName) Then Return ""
            Return mFilters(FilterName)
        End Get
    End Property
#End Region
#Region "Form"
    Private _frm As New frmMyFilters
    Public ReadOnly Property IsVisible As Boolean
        Get
            Return _frm.Visible
        End Get
    End Property
    Public Sub ShowForm(Optional owner As Form = Nothing)
        Try
            If IsNothing(owner) Then
                _frm.Show()
            Else
                _frm.ShowDialog(owner)
            End If
        Catch ex As Exception

        End Try
    End Sub
    Public Sub HideForm()
        Try
            _frm.Hide()
        Catch ex As Exception

        End Try
    End Sub
    Public Sub CloseForm()
        Try
            _frm.Close()
        Catch ex As Exception

        End Try
    End Sub
#End Region
End Class
